﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace dev173d
{
    class Weapon:GameObject3D
    {
        
        private Model model;
        private Game game;

        private static float XOFFSET = 0.9f;
        private static float YOFFSET = -0.9f;
        private static float ZOFFSET = 3.2f;

        float weaponpositionX;
        float weaponpositionY;
        float weaponpositionZ;
        float angulodeMiraX;
        float angulodeMiraY;
        float angulodeMiraZ;

        float sightDegreesX = 0;
        float sightDegreesY = 90;
        float sightDegreesZ = 0;

        //private static float XOFFSET = 0.9f;
        //private static float YOFFSET = -0.4f;
        //private static float ZOFFSET = 0.8f;

        //private static float XOFFSET = 0.0f;
        //private static float YOFFSET = -0.3f;
        //private static float ZOFFSET = -1.5f;



    

        private Matrix matrixT;


        public Weapon(Game game, Model model, BasicCamera camera) : base(game,camera,model)

        {
            
            this.Scale = 0.2f;


            matrixT = Matrix.Identity * Matrix.CreateRotationY(MathHelper.ToRadians(sightDegreesY)) 
                * Matrix.CreateRotationX(MathHelper.ToRadians(sightDegreesX)) 
                * Matrix.CreateRotationZ(MathHelper.ToRadians(sightDegreesZ));

            //matrixT = Matrix.Identity * Matrix.CreateRotationY(MathHelper.ToRadians(90)) * Matrix.CreateRotationX(MathHelper.ToRadians(-8));

            
            this.ModelTransform(matrixT);
        }


        public override void Update(GameTime gameTime)
        {
            Vector3 pos = camera.Position;

            pos += -camera.ZAxis * ZOFFSET;
            pos += camera.YAxis * YOFFSET;
            pos += camera.XAxis * XOFFSET;

            this.Position = pos;

            this.RotationXDegrees = camera.AngleDegreesY ;
            this.RotationYDegrees = camera.AngleDegreesX ;

            

            base.Update(gameTime);

        }


       // protected static Model GetModel(Game game)
       // {
            //return game.Content.Load<Model>("wasphunter");
        //}

        #region Setar parametros para mira


        public float WeaponPositionX
        {
            get{ return weaponpositionX;}

            set
            {
                weaponpositionX = value;
                XOFFSET = weaponpositionX;
            }
        }
        public float WeaponPositionY
        {
            get { return weaponpositionY; }

            set
            {
                weaponpositionY = value;
                YOFFSET = weaponpositionY;
            }
        }
        public float WeaponPositionZ
        {
            get { return weaponpositionZ; }

            set
            {
                weaponpositionZ = value;
                ZOFFSET = weaponpositionZ;
            }
        }
        public float AngulodeMiraX
        {
            get { return angulodeMiraX; }

            set
            {
                angulodeMiraX = value;
                sightDegreesX = angulodeMiraX;
            }
        }

        public float AngulodeMiraY
        {
            get { return angulodeMiraY; }

            set
            {
                angulodeMiraY = value;
                sightDegreesY = angulodeMiraY;
            }
        }

        public float AngulodeMiraZ
        {
            get { return angulodeMiraZ; }

            set
            {
                angulodeMiraZ = value;
                sightDegreesZ = angulodeMiraZ;
            }
        }

        #endregion


    }
}
